//
//  FTableViewCell.m
//  YiQiTingShu
//
//  Created by dllo on 15/11/5.
//  Copyright © 2015年 直到世界的尽头. All rights reserved.
//

#import "FTableViewCell.h"

@interface FTableViewCell ()
@property(nonatomic, strong)UIImageView *timeImageView;
@property(nonatomic, strong)UIImageView *countImageView;
@property(nonatomic, strong)UIButton *downButton;
@end

@implementation FTableViewCell

- (void)awakeFromNib {
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

#pragma mark - 懒加载
-(UIImageView *)mainImageView
{
    if (!_mainImageView) {
        _mainImageView = [[UIImageView alloc] init];
        [self addSubview:_mainImageView];
    }
    return _mainImageView;
}

-(UILabel *)titleLabel
{
    if (!_titleLabel) {
        _titleLabel = [[UILabel alloc] init];
        [_titleLabel NightWithType:UIViewColorTypeNormal];
        [self addSubview:_titleLabel];
    }
    return _titleLabel;
}

-(UILabel *)subTitle
{
    if (!_subTitle) {
        _subTitle = [[UILabel alloc] init];
        [_subTitle NightWithType:UIViewColorTypeNormal];
        [self addSubview:_subTitle];
    }
    return _subTitle;
}

-(UILabel *)timeLabel
{
    if (!_timeLabel) {
        _timeLabel = [[UILabel alloc] init];
        [_titleLabel NightWithType:UIViewColorTypeNormal];
        [self addSubview:_timeLabel];
    }
    return _timeLabel;
}

-(UILabel *)byLabel
{
    if (!_byLabel) {
        _byLabel = [[UILabel alloc] init];
        [_byLabel NightWithType:UIViewColorTypeNormal];
        [self addSubview:_byLabel];
    }
    return _byLabel;
}

-(UILabel *)countLabel
{
    if (!_countLabel) {
        _countLabel = [[UILabel alloc] init];
        [_countLabel NightWithType:UIViewColorTypeNormal];
        [self addSubview:_countLabel];
    }
    return _countLabel;
}

-(UIImageView *)countImageView
{
    if (!_countImageView) {
        _countImageView = [[UIImageView alloc] init];
        [self addSubview:_countImageView];
    }
    return _countImageView;
}

-(UIImageView *)timeImageView
{
    if (!_timeImageView) {
        _timeImageView = [[UIImageView alloc] init];
        [self addSubview:_timeImageView];
    }
    return _timeImageView;
}

-(UIButton *)downButton
{
    if (!_downButton) {
        _downButton = [UIButton buttonWithType:UIButtonTypeCustom];
        [self addSubview:_downButton];
//        [_downButton setImage:[UIImage imageNamed:@"f-xiazai"] forState:UIControlStateNormal];
    }
    return _downButton;
}

-(void)setTypes:(FTableViewCellType)types
{
    switch (types) {
        case FTableViewCellTypePlayList:
            self.titleLabel.frame = CGRectMake(FitConstant_XorWidth(10), FitConstant_YorHeight(8), self.frame.size.width - FitConstant_XorWidth(10) - FitConstant_XorWidth(45), FitConstant_YorHeight(30));
            self.countImageView.frame = CGRectMake(FitConstant_XorWidth(7), FitConstant_YorHeight(40), FitConstant_XorWidth(15), FitConstant_YorHeight(15));
            _countImageView.image = [UIImage imageNamed:@"sanjiao1"];
            
            self.countLabel.frame = CGRectMake(_countImageView.frame.origin.x + _countImageView.frame.size.width, _countImageView.frame.origin.y, 40, 15);
            _countLabel.font = [UIFont systemFontOfSize:12];
            
            self.timeImageView.frame = CGRectMake(_countLabel.frame.origin.x + _countLabel.frame.size.width, _countLabel.frame.origin.y, FitConstant_XorWidth(15), FitConstant_YorHeight(15));
            _timeImageView.image = [UIImage imageNamed:@"f-shijian"];
            
            self.timeLabel.frame = CGRectMake(_timeImageView.frame.origin.x + _timeImageView.frame.size.width, _timeImageView.frame.origin.y, FitConstant_XorWidth(100), FitConstant_YorHeight(15));
            _timeLabel.font = [UIFont systemFontOfSize:12];
            self.downButton.frame = FitRectMake(335, 15, 30, 30);
            [_downButton addTarget:self action:@selector(downButtonAction) forControlEvents:UIControlEventTouchUpInside];
            break;
        case FTableViewCellTypeList:
            self.mainImageView.frame = CGRectMake(5 * FitWidth, 5 * FitHeight, FitHeight * 70, FitHeight * 70);
            self.titleLabel.frame = CGRectMake(FitConstant_XorWidth(80), FitConstant_YorHeight(8), self.frame.size.width - FitConstant_XorWidth(10), FitConstant_YorHeight(30));
            
            self.byLabel.frame = CGRectMake(FitConstant_XorWidth(80), FitConstant_YorHeight(45), self.titleLabel.frame.size.width, FitConstant_YorHeight(30));
            
            self.countImageView.frame = CGRectMake(FitConstant_XorWidth(80), FitConstant_YorHeight(80), FitConstant_XorWidth(15), FitConstant_YorHeight(15));
            _countImageView.image = [UIImage imageNamed:@"sanjiao1"];
            
            self.countLabel.frame = CGRectMake(_countImageView.frame.origin.x + _countImageView.frame.size.width, _countImageView.frame.origin.y, 40, 15);
            _countLabel.font = [UIFont systemFontOfSize:12];
            
            self.timeImageView.frame = CGRectMake(_countLabel.frame.origin.x + _countLabel.frame.size.width, _countLabel.frame.origin.y, FitConstant_XorWidth(15), FitConstant_YorHeight(15));
            _timeImageView.image = [UIImage imageNamed:@"f-shijian"];
            
            self.timeLabel.frame = CGRectMake(_timeImageView.frame.origin.x + _timeImageView.frame.size.width, _timeImageView.frame.origin.y, FitConstant_XorWidth(100), FitConstant_YorHeight(15));
            _timeLabel.font = [UIFont systemFontOfSize:12];
            self.downButton.frame = FitRectMake(335, 60, 30, 30);
            [_downButton addTarget:self action:@selector(downButtonAction) forControlEvents:UIControlEventTouchUpInside];
            break;
            
        default:
            break;
    }
}

-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        [self NightWithType:UIViewColorTypeNormal];
    }
    return self;
}

-(void)downButtonAction
{
    self.block();
}

@end
